package com.ljkj.cordial.chat.ui;

/**
 * @description:
 * @author: Panwei
 * @date: 2019/12/6 19:08
 */
public class ChatUtils {

    private ChatUtils() {
    }

    public static String createMessageId(long id, String fromId, String toId) {
        return id + "#" + fromId + toId + "#" + System.currentTimeMillis();
    }

    public static String createMessageId(long id, String fromId, String toId, long timestamp) {
        return id + "#" + fromId + toId + "#" + timestamp;
    }

    public static long analysisTimestampInMessageId(String msgId) {
        try {
            return Long.parseLong(msgId.substring(msgId.lastIndexOf("#") + 1));
        } catch (Exception e) {
            return System.currentTimeMillis();
        }
    }
}
